var ns;
app = new Vue({
    el: '#app',
    data: {
        username: '',
        headimg: '',
        positionname: '',
        companyName: ''
    },
    methods: {
        get_data: function() {
            api.toast({
                msg: '刷新成功',
                duration: 2000,
                location: 'bottom'
            });
        },
        open_organization: function() {
            var that = this;
            ns.openWin('organization_frm', '组织架构');
        },
        open_mycenter: function() {
            var that = this;
            ns.openWin('gerenzhongxin_frm', '个人中心');
        },
        open_setting: function() {
            var that = this;
            ns.openWin('setting_frm', '系统设置');
        },
        get_user_data: function() {
            var that = this;
            var companyName = api.getPrefs({
                sync: true,
                key: 'companyName'
            });
            that.companyName = companyName || '重庆永友网络科技有限公司';
            var username = api.getPrefs({
                sync: true,
                key: 'username'
            });
            var positionname = api.getPrefs({
                sync: true,
                key: 'positionname'
            });
            that.positionname = positionname || '暂时没有岗位';
            that.username = username || '匿名用户';
            var headimg = api.getPrefs({
                sync: true,
                key: 'headimg'
            });

            that.headimg = headimg || '../image/default.png';
        },
    }
});
apiready = function() {
    api.parseTapmode();
    ns = window.Foresight.Util;
    app.get_user_data();
    api.addEventListener({
        name: 'changecentersuccess'
    }, function(ret, err) {
        if (ret) {
            app.get_user_data();
        } else {}
    });

};
